
#
# This class contains all the user related specializations for 
# this application.
#

#require_dependency 'ldap_user'

class User < LdapUser # LoginUser if not using LDAP authentication
  # Create a default admin user
  #
  def self.bootstrap
    return if self.count > 0
    
    u = self.new
    Thread.current[:session] = {}
    self.current = u
    
    u.login = 'admin'
    u.email = 'admin@acme.com'
    u.name = 'Mr. Admin'
    u.admin = 1
    u.is_local = 1
    u.reset_password 'admin'
    u.save
  end
  
  def self.bootstrap_user(name)
    u = self.new
    u.login = name
    u.email = "#{name}@acme.com"
    u.name = name.capitalize
    u.admin = 0
    u.is_local = 1
    u.reset_password name
    u.save
  end
  
end
